package com;

import java.util.Random;

public class Demo3 {
	public static void main(String[] args) {
		int[][] a = new int[3][5];
		int[] aver = new int[a.length];
		generateRand(a);
		out(a);
		average(a, aver);
		out(aver);
	}

	private static void generateRand(int[][] a) {
		Random r = new Random();
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				a[i][j] = r.nextInt(100);
			}
		}
	}

	public static void average(int[][] a, int[] sum) {

		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++)
				sum[i] = sum[i] + a[i][j];
			sum[i] /= a[i].length;
		}

	}

	private static void out(int[][] a) {
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.print(a[i][j] + "\t");
			}
			System.out.println();
		}
	}

	private static void out(int[] aver) {
		for (int i = 0; i < aver.length; i++) {
			System.out.print(aver[i] + "  ");
		}
	}
}